package com.qumitech.visualnovel.controller.rest;

import com.qumitech.visualnovel.component.annotation.RequireWhiteList;
import com.qumitech.visualnovel.model.common.BaseRsp;
import com.qumitech.visualnovel.pubdef.dto.withdraw.WithdrawRuleConfigNewDTO;
import com.qumitech.visualnovel.service.withdraw.WithdrawRuleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/api/withdraw/rule")
public class WithdrawRuleController {
    @Autowired
    private WithdrawRuleService withdrawRuleService;


    @RequireWhiteList
    @GetMapping("/cfg")
    public BaseRsp listWithdrawRuleConfig(@RequestParam(value = "wallet_type") Byte walletType){
        Map<String, Object> reqMap = new HashMap<>();
        reqMap.put("wallet_type", walletType);
        return withdrawRuleService.listWithdrawRuleConfig(reqMap);
    }

    @RequireWhiteList
    @PostMapping("/cfg")
    public BaseRsp createWithdrawRuleConfig(@RequestBody WithdrawRuleConfigNewDTO newDTO){
        return withdrawRuleService.addWithdrawRuleConfig(newDTO);
    }

    @RequireWhiteList
    @DeleteMapping("/cfg/{cfg_id}")
    public BaseRsp deleteWithdrawRuleConfig(@PathVariable("cfg_id") String cfgId){
        return withdrawRuleService.deleteWithdrawRuleConfig(cfgId);
    }
}
